--- mkinitrd.dist	2016-06-13 03:51:29.000000000 +0200
+++ mkinitrd	2016-09-23 12:46:52.645297632 +0200
@@ -44,6 +44,9 @@
 #   Yada yada yada.
 # Modified by Patrick Volkerding <volkerdi@slackware.com> 21 August 2012
 #   Add Btrfs multi-device filesystem support option (-B).
+# Modified by Marek Wodzinski <majek@mamy.to> 12 March 2015
+#   Added copying of thin-provisioning-tools if available and LVM
+#   support enabled. It's required to start root volume with dm-cache.
 
 MKINITRD_VERSION=1.4.8
 
@@ -537,6 +540,14 @@
     mkdir -p $SOURCE_TREE/lib/udev/rules.d
     echo 'KERNEL=="dm-[0-9]*", OPTIONS+="db_persist"' > \
       $SOURCE_TREE/lib/udev/rules.d/95-dm-initrd.rules
+    # Include thin-provisioning-tools (dm-cache and dm-thin support)
+    if [ -f /usr/sbin/pdata_tools ]; then
+      PDATA_BASEDIR=/usr/sbin	#it should be in /sbin, but default Slackware lvm2 is compiled with path to /usr/sbin :-(
+      mkdir -p $SOURCE_TREE/$PDATA_BASEDIR
+      cp $PDATA_BASEDIR/pdata_tools $SOURCE_TREE/$PDATA_BASEDIR/pdata_tools
+      ( cd $SOURCE_TREE/$PDATA_BASEDIR
+        find $PDATA_BASEDIR -lname pdata_tools | xargs -n1 basename | xargs -n1 ln -s pdata_tools 2>/dev/null )
+    fi
   else
     echo "LVM binary is missing, LVM support isn't installed"
   fi
